package algorithms;

public class Stack {
	public Element head = null;
	
	public void PUSH(Element elem){
		if(head == null){
			head = elem;
			return;
		}
		if(head != null){
			elem.next = head;
			head = elem;
			return;
		}
	}
	
	public Element POP(){
		Element cur = head;
		head = head.next;
		return cur;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("[ ");
		Element current = head;
		while (current != null){
			sb.append(current.ch + " ");
			current = current.next;
		}
		sb.append("]");
		return sb.toString();
	}
}
